import { Injectable } from '@angular/core';

import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Global } from 'src/global';
import { User } from './user';


@Injectable({
  providedIn: 'root'
})
export class UserService {

  constructor(private http: HttpClient) { }
  url = Global.commonURL+'/userlist';
 
  getUsers():Observable<any> {
    return this.http.get(this.url);
  }
  deleteUser(user:User){
    const url = Global.commonURL+'/deleteuser';
    return this.http.post(url,{"user":user});

  }
  editUser(user:User,old_user:string){
    const url = Global.commonURL+'/edituser';
    return this.http.post(url,{"user":user,"old_user":old_user});

  }
  addUser(user:User){
    const url = Global.commonURL+'/adduser';
    // $('#identifier').modal('hide')
    return this.http.post(url,{"user":user});

  }

}
